package home

import (
	"fmt"
	beego "github.com/beego/beego/v2/adapter"
	"quickstart/services"
)

type BaseController struct {
	beego.Controller
	Auth services.AuthService
}

func (bc *BaseController) Prepare() {
	token := bc.Ctx.GetCookie("token")
	fmt.Println(token)
	if token != "" {
		var sa services.AuthService
		sa.Init(token)
		bc.Auth = sa
	}
	fmt.Println(bc.Auth)
	bc.Data["user"] = bc.Auth.User
}
